package pers.mihao.quickstream.common.util.scan;

import org.springframework.core.env.Environment;
import org.springframework.util.ClassUtils;

/**
 * @author mihao
 * @since 2023/3/7
 */
public class SpringEnvironmentPackageResolve implements PackageResolve{

    private Environment environment;

    public SpringEnvironmentPackageResolve(Environment environment) {
        this.environment = environment;
    }

    @Override
    public String resolvePackage(String basePackage) {
        return ClassUtils.convertClassNameToResourcePath(this.getEnvironment().resolveRequiredPlaceholders(basePackage));
    }

    public Environment getEnvironment() {
        return environment;
    }
}
